<template>
  <div>
    <div style="margin-top:20px" class="qup-title-box"><span class="border" /><span>图纸信息</span></div>
    <el-form
      ref="refForm1"
      :rules="formRules"
      :model="formData"
      size="mini"
      label-width="150px"
    >

      <el-row>
        <el-col :span="8">
          <el-form-item label="图纸编号:" prop="picCode">
            <el-input v-model="formData.picCode" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="图纸名称:" prop="picName">
            <el-input v-model="formData.picName" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="图纸状态:" prop="picStatus">
            <el-select
              v-model="formData.picStatus"
              style="width: 100%"
              disabled
            >
              <el-option
                v-for="item in picStatusList"
                :key="item.dictCode"
                :label="item.dictName"
                :value="item.dictCode"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="16">
          <el-form-item label="设计区域:" prop="designSpace">
            {{ this.$getAreaName(formData.designSpace) }}
          </el-form-item>
        </el-col>

      </el-row>
    </el-form>
    <c-table-box ref="cTableBox" index hide-func :setting="false" :data="formData.designPictureMaintainDTOList" no-request :table-config="tableConfig">
      <el-table-column slot="before" type="expand" width="50">
        <template v-slot="{row}">
          <div style="padding:10px">
            <c-table-box :index="false" :data="row.shopAttachmentDTOList" hide-func :setting="false" :table-config="tableConfigAtt" />
          </div>
        </template>
      </el-table-column>
    </c-table-box>
  </div>
</template>
<script>
import { getDictByPatchType } from '@/api/dataDict'
export default {
  name: 'DrawingInfo',
  props: {
    baseInfo: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      formData: {},
      formRules: {},
      picStatusList: [],
      tableConfig: {
        setting: [
          {
            prop: 'picBatchCode',
            label: '图纸批号',
            minWidth: 120
          },
          {
            prop: 'pictureNature',
            label: '图纸性质',
            minWidth: 120,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'PICTURE_NATURE'
            }
          },
          {
            prop: 'isNeedAdjustOutpicDetail',
            label: '是否需要修改出图明细',
            minWidth: 160,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'BOOLEANS'
            }
          },
          {
            prop: 'isNeedApproval',
            label: '是否需要审批',
            minWidth: 140,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'BOOLEANS'
            }
          },
          {
            prop: 'isValid',
            label: '是否有效',
            minWidth: 120,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'BOOLEANS'
            }
          },
          {
            prop: 'customerConfirmResult',
            label: '经销商确认结果',
            minWidth: 120,
            render: (h, row) => {
              return h('span', this.resultHandle(row.customerConfirmResult))
            }
          },
          {
            prop: 'customerFeedbackAdvice',
            label: '经销商反馈意见',
            minWidth: 140
          },
          {
            prop: 'managerReviewResult',
            label: '客户经理审核结果',
            minWidth: 140,
            formatData: row => {
              const v = row.managerReviewResult
              if (v === 1 || v === '1') {
                return '同意商家确认结果'
              } else if (v === 0 || v === '0') {
                return '不同意商家确认结果'
              }
              return ''
            }
          },
          {
            prop: 'managerReviewAdvice',
            label: '客户经理审核意见',
            minWidth: 140
          },
          {
            prop: 'newBusinessAreaSummary',
            label: '新业务面积',
            minWidth: 140
          },
          {
            prop: 'haveEAndC',
            label: '是否含成融定',
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'BOOLEANS'
            },
            minWidth: 140
          }

          // {
          //   prop: '',
          //   label: '操作',
          //   minWidth: 140,
          //   render: (h, row) => {
          //     return h('el-button', {
          //       props: {
          //         type: 'text'
          //       },
          //       on: {
          //         click: () => {
          //           this.row = row
          //           this.$refs.appLog.openDialog()
          //         }
          //       }
          //     }, '查看审批记录')
          //   }
          // }
        ]
      },
      tableConfigAtt: {
        setting: [
          {
            prop: '',
            label: '图纸预览',
            width: 120,
            render: (h, row) => {
              return h('c-accessory', {
                props: {
                  src: row.attachmentUrl,
                  type: row.typeName,
                  width: '100px',
                  height: '60px'
                }
              })
            }
          },
          {
            prop: 'attachmentName',
            label: '图纸名称',
            minWidth: 200
          },
          {
            prop: 'typeName',
            label: '附件类型',
            width: 120
          },
          {
            prop: '',
            label: '操作',
            className: 'btn-green',
            width: 120,
            render: (h, row) => {
              return h('el-button', {
                props: {
                  type: 'text'
                },
                on: {
                  click: () => {
                    this.fileDown(row)
                  }
                }
              }, '下载')
            }
          }
        ]
      }
    }
  },
  watch: {
    baseInfo: {
      handler(v) {
        this.formData = v
      },
      deep: true,
      immediate: true
    }
  },
  async  created() {
    const { PIC_DESIGN_STATE } = await getDictByPatchType(['PIC_DESIGN_STATE'])
    this.picStatusList = PIC_DESIGN_STATE
  },
  methods: {
    resultHandle(v) {
      return v === undefined || v === '' || v === null ? '' : v.toString() === '1' ? '同意' : '不同意'
    },
    fileDown(row) {
      this.$downFile(row)
    }
  }
}
</script>
